//
//  CommentLevelView.m
//  YJRenter
//
//  Created by 文彬 on 2018/7/9.
//  Copyright © 2018年 文彬. All rights reserved.
//

#import "CommentLevelView.h"

@interface CommentLevelView()

@property (strong, nonatomic) UIImageView *headImgView;
@property (strong, nonatomic) UIButton *topBtn;
@property (strong, nonatomic) UIButton *middleBtn;
@property (strong, nonatomic) UIButton *lowBtn;
@end

@implementation CommentLevelView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (id)init{
    self = [super init];
    if (self) {
        
        [self initControl];
    }
    return self;
}

-(void)initControl{
        
    [self addSubview:self.headImgView];
    [self addSubview:self.topBtn];
    [self addSubview:self.middleBtn];
    [self addSubview:self.lowBtn];
    
    [self.headImgView setRoundImageWithURL:@"https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4036889747,3526425271&fm=27&gp=0.jpg" placeholderImage:nil];
}

- (void)layoutSubviews{
    
    CGFloat height = self.frame.size.height;
    
    [self.headImgView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.centerY.equalTo(self.centerY);
        make.width.height.equalTo(@(height-10));
    }];
    
    [self.topBtn makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@60);
        make.width.equalTo(@70);
        make.height.equalTo(@40);
        make.centerY.equalTo(self.centerY);
    }];
    
    [self.middleBtn makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@150);
        make.width.equalTo(@70);
        make.height.equalTo(@40);
        make.centerY.equalTo(self.centerY);
    }];
    
    [self.lowBtn makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@260);
        make.width.equalTo(@70);
        make.height.equalTo(@40);
        make.centerY.equalTo(self.centerY);
    }];
}
#pragma mark getter
- (UIImageView*)headImgView{
    if (_headImgView==nil) {
        _headImgView = [[UIImageView alloc]init];
    }
    
    return _headImgView;
}

- (UIButton*)topBtn{
    if (_topBtn==nil) {
        _topBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_topBtn setTitle:@"好评" forState:UIControlStateNormal];
        [_topBtn setImage:[UIImage imageNamed:@"user_setting"] forState:UIControlStateNormal];
        _topBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 30);
        _topBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [_topBtn setTitleColor:kMainOriginColor forState:UIControlStateNormal];
    }
    return _topBtn;
}
- (UIButton*)middleBtn{
    if (_middleBtn==nil) {
        _middleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_middleBtn setTitle:@"中评" forState:UIControlStateNormal];
        [_middleBtn setImage:[UIImage imageNamed:@"user_setting"] forState:UIControlStateNormal];
        _middleBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 30);
        _middleBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [_middleBtn setTitleColor:kTitleColor forState:UIControlStateNormal];
    }
    return _middleBtn;
}
- (UIButton*)lowBtn{
    if (_lowBtn==nil) {
        _lowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_lowBtn setTitle:@"差评" forState:UIControlStateNormal];
        [_lowBtn setImage:[UIImage imageNamed:@"user_setting"] forState:UIControlStateNormal];
        _lowBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 30);
        _lowBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [_lowBtn setTitleColor:kTitleColor forState:UIControlStateNormal];
    }
    return _lowBtn;
}

@end
